package cn.yusei.teamTribe.util;

import cn.yusei.teamTribe.dao.user.po.StudentPO;
import cn.yusei.teamTribe.entity.Student;
import cn.yusei.teamTribe.entity.school.School;
import cn.yusei.teamTribe.entity.school.SchoolManager;
import cn.yusei.teamTribe.exception.SchoolNotFoundException;

public class StudentUtil {

	public static void studentToPO(Student student, StudentPO studentPO)
	{
		School school = SchoolManager.get(student.getSchoolId());
		if(school == null)
			throw new SchoolNotFoundException("SchoolId : " + student.getSchoolId() + " 没有找到");
		studentPO.setSchoolId(student.getSchoolId());
		studentPO.setNo(student.getNo());
		studentPO.setName(student.getName());
		studentPO.setGender(student.getGender());
		studentPO.setBirthday(student.getBirthday());
		studentPO.setAcademy(school.getAcademyValue(student.getAcademy()));
		studentPO.setMajor(school.getMajorValue(student.getMajor()));
		studentPO.setGrade(student.getGrade());
		studentPO.setCla(student.getCla());
	}
	
	public static void poToStudent(StudentPO studentPO, Student student)
	{
		School school = SchoolManager.get(studentPO.getSchoolId());
		if(school == null)
			throw new SchoolNotFoundException("SchoolId : " + studentPO.getSchoolId() + " 没有找到");
		student.setSchoolId(studentPO.getSchoolId());
		student.setNo(studentPO.getNo());
		student.setName(studentPO.getName());
		student.setGender(studentPO.getGender());
		student.setBirthday(studentPO.getBirthday());
		student.setAcademy(school.getAcademyName(studentPO.getAcademy()));
		student.setMajor(school.getMajorName(studentPO.getMajor()));
		student.setGrade(studentPO.getGrade());
		student.setCla(studentPO.getCla());
	}
}
